package com.hhf.rpc.core.enums;

import lombok.Getter;

/**
 * @Author hhf
 * @Date 2024/10/19
 * @Description
 */
@Getter
public enum ProtocolMessageStatusEnum {

    /**
     * 成功
     */
    OK("ok", 20),
    /**
     * 请求失败
     */
    FAILREQUEST("failRequest", 40),
    /**
     * 响应失败
     */
    FAILRESPONSE("failResponse", 50);

    private final String text;

    private final int value;

    ProtocolMessageStatusEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }


    /**
     * 根据value获取枚举类
     * @param value
     * @return
     */
    public static ProtocolMessageStatusEnum getEnumByValue(int value){

        for (ProtocolMessageStatusEnum statusEnum: ProtocolMessageStatusEnum.values()){
            if (value == statusEnum.value){
                return statusEnum;
            }
        }
        return null;
    }

}
